//
//  ItemView.swift
//  HisPaste
//
//  Created by 烟雀 on 2024/2/22.
//

import Foundation

import SwiftUI

struct ItemView: View{
    
    var data: String
    var maxLen = 30
    
    @State
    var spread = false
    
    var body: some View{
        HStack{
            
            if data.count > maxLen{
                Text(spread ? data : "\(String(data.prefix(maxLen)))...")
                Spacer()
                Button(action: {
                    self.spread = !self.spread
                }, label: {
                    Text("展/折").foregroundColor(Color.black)
                })
                    .help("展开/折叠")
                    .background(Color.accentColor)
                    .cornerRadius(15)
            } else {
                Text(data)
            }
            
        }
    }
}
